using System;
using System.Data.Linq;
using System.Linq.Expressions;

namespace SmartClientPlatform.RemoteClientBase
{
    public interface IScopeItem<T>
    {
        IScopeItem<T> Rel<TProperty>(
            Expression<Func<T, TProperty>> expression,
            Action<IScopeItem<TProperty>> action);

        IScopeItem<T> Rel<TSetItem>(
            Expression<Func<T, EntitySet<TSetItem>>> expression,
            Action<IScopeItem<TSetItem>> action)
            where TSetItem : class;

        IScopeItem<T> Field<TProperty>(Expression<Func<T, TProperty>> expression);
    }

    public static class ScopeItemExtentions
    {
        public static IScopeItem<T> Rel<T, TProperty>(
            this IScopeItem<T> it,
            Expression<Func<T, TProperty>> expression)
        {
            return it.Rel(expression, delegate { });
        }
    }
}